package com.sky.mapper;

import com.sky.entity.User;
import org.apache.ibatis.annotations.Mapper;
import org.apache.ibatis.annotations.Select;

import java.time.LocalDate;
import java.util.Map;

@Mapper
public interface UserMapper {
    /**
     * 查询user是否存在
     *
     * @param openid
     * @return
     */
    @Select("SELECT * FROM user WHERE openid=#{opendid}")
    public User selectUserByOpendId(String openid);

    void insert(User user);

    @Select("SELECT * FROM user WHERE id=#{userId}")
    User getById(Long userId);

    @Select("select count(id) from user where date(create_time)=#{localDate}")
    Integer selectNewUser(LocalDate localDate);

    @Select("select count(id) from user where date(create_time)<=#{localDate}")
    Integer selectAllUser(LocalDate localDate);

    Integer countByMap(Map map);
}
